'use strict';

const Controller = require('egg').Controller;

class SingerController extends Controller {
  async index() {
    const { ctx } = this;
    // console.log(ctx.request.body)
    var db = this.app.mongodb;
    var {item} = ctx.request.body
    var res = await db.collection("singer").find({ id:item.id }).toArray()
    if (res.length) {
        ctx.body = {
          code: 400,
          msg: "已关注"
        }
      } else {
        var ent = await db.collection("singer").insertOne(item)
        ctx.body = {
          code: 200,
          msg: "关注成功"
        }
      }
  }
}

module.exports = SingerController;
